package com.xayy.mgt.model;

import cn.kawins.mybatis.base.BaseModel;
import cn.kawins.mybatis.interceptor.FillingCreateTime;
import cn.kawins.mybatis.interceptor.InsertAutoFilling;
import cn.kawins.mybatis.interceptor.UpdateAutoFilling;
import cn.kawins.mybatis.util.SnowflakeId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.xayy.mgt.enums.SeriousDegreeEnum;
import io.swagger.annotations.ApiModelProperty;
import tk.mybatis.mapper.annotation.KeySql;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import lombok.*;
/**
 * 历史故障表(HistoryFault)实体类
 *
 * @author zhangxa
 * @since 2023-08-21 11:48:28
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "health_xw.t_history_fault")
@EqualsAndHashCode(callSuper = true)
public class HistoryFault extends BaseModel<Long> {
    @Id
    @ApiModelProperty(value = "主键")
    @Column(name = "id")
    @KeySql(genId = SnowflakeId.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /**
     * 节点id
     */
    @Column(name = "node_id")
    private Long nodeId;

    /**
     * 卫星id
     */
    @Column(name = "satellite_id")
    private Long satelliteId;

    /**
     * 异常时间
     */
    @Column(name = "exception_time")
    private Date exceptionTime;
    /**
     * 同步时间
     */
    @Column(name = "synchronous_time")
    private Date synchronousTime;
    /**
     * 异常名称
     */
    @Column(name = "exception_name")
    private String exceptionName;


    /**
     * 部件/分系统
     */
    @Column(name = "components")
    private String components;

    /**
     * 持续时间
     */
    @Column(name = "persistence_time")
    private String persistenceTime;
    /**
     * 严重程度
     */
    @Column(name = "serious_degree")
    @ApiModelProperty(value = "严重程度")
    private Integer seriousDegree;

    @Transient
    private String seriousDegreeString;

    public void setSeriousDegree(Integer seriousDegree) {
        this.seriousDegree = seriousDegree;
        this.seriousDegreeString = SeriousDegreeEnum.valueof(seriousDegree);
    }


    public void getSeriousDegreeString(String seriousDegreeString) {
        this.seriousDegreeString = seriousDegreeString;
        this.seriousDegree = SeriousDegreeEnum.valueof(seriousDegreeString);
    }
    /**
     * 卫星名称
     */
    @Column(name = "satellite_name")
    private String satelliteName;

    /**
     * 创建时间
     */
    @Column(name = "created_time")
    @InsertAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "创建时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date createdTime;
    /**
     * 更新时间
     */
    @Column(name = "updated_time")
    @UpdateAutoFilling(value = FillingCreateTime.class)
    @ApiModelProperty(value = "最后更新时间", accessMode = ApiModelProperty.AccessMode.READ_ONLY, example = "2010-01-01 00:00:00")
    private Date updatedTime;
}